<template>
    <div id="payOk">
        <div class="payYes">
            <div class="payYes-top">
                <i class="iconfont icon-danxuan"></i>
            </div>
            <div class="pay-text">支付成功</div>
        </div>
    </div>
</template>

<script>
    import {userService} from '../../service/userService'
    export default {
        data(){
            return{

            }
        },
        mounted:function(){
            var that = this;
            that.urlResolve()
        },
        methods:{
            urlResolve(){
                let that = this;
                //判断是否有token
                let token = window.localStorage.getItem('token')
                if(token){
                    let shopid =window.localStorage.getItem('pathId')
                    let url = location.search; //获取url中"?"符后的字串
                    let theRequest = new Object();
                    if (url.indexOf("?") != -1) {
                        let str = url.substr(1);
                        let strs = str.split("&");
                        for(let i = 0; i < strs.length; i ++) {
                            theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
                        }
                    }
                    userService.getOrders(theRequest.orderNo).then(function(res){
//                    console.log(res);
                        let order = res.data.datas
                        let orderType = res.data.datas.orderType;
                        let shopId = window.localStorage.getItem('pathId')
                        if(orderType === 2){
                            //活动支付
                            window.localStorage.removeItem('checked')
                            let orderId = window.localStorage.getItem('orderNo');
                            that.$router.push({path:'/payment/'+orderId +'/'+ orderType})
                        }
                        if(orderType === 3){
                            //知识支付
                            let orderId = window.localStorage.getItem('orderId');
                            window.localStorage.removeItem('checked');
                            that.$router.push({path:'/columns/'+orderId})
                        }
                        if(orderType === 5){
                            //VIP支付
                            window.localStorage.removeItem('checked');
                            that.$router.push({path:'/vip'})
                        }
                        if(orderType === 6){
                            //直播支付
                            window.localStorage.removeItem('checked')
                            let orderId = window.localStorage.getItem('orderId')
                            that.$router.push({path:'/lives/' + orderId});
                        }
                    })
                }else{

                }
            }
        },
    }
</script>

<style lang="less">
    #payOk{
        width:100%;
        height:3rem;
        max-width:450px;
        margin:0 auto;
        .payYes{
            width:4rem;
            height:4rem;
            position:fixed;
            left:0;
            right:0;
            top:0;
            bottom:0;
            margin:auto;
            text-align: center;
            .payYes-top{
                color:limegreen;
                i{
                    font-size:86px;
                }
            }
            .pay-text{
                margin-top: 1rem;
                font-size: 16px;
                color: #333;
            }
        }
    }
</style>